package com.pickgliss.ui.image
{
	import com.pickgliss.ui.ComponentFactory;
	import com.pickgliss.ui.image.ScaleLeftRightImage;
	import com.pickgliss.utils.ObjectUtils;
	
	import flash.display.Bitmap;
	
	public class ScaleLeftRightIconButton extends ScaleLeftRightImage
	{
		public function ScaleLeftRightIconButton()
		{
			super();
		}
		
		public var IconString : String;
		private var _titleIma  : Bitmap;
		private var _oldWidth  : int;
		override protected function creatImages():void
		{
			super.creatImages();
			if(IconString)
			{
				_titleIma = ComponentFactory.Instance.creat(IconString);
				_oldWidth = _titleIma.width;
			}
			
		}
		override protected function removeImages():void
		{
			super.removeImages();
			ObjectUtils.disposeObject(_titleIma);
		}
		override protected function addChildren():void
		{
			super.addChildren();
			if(_titleIma)addChild(_titleIma);
		}
		override protected function drawImage():void
		{
			super.drawImage();
			if(_titleIma)
			{
				_titleIma.x = int((_width - _titleIma.width)/2);
				_titleIma.y = int((_height - _titleIma.height)/2);
			}
		}
	}
}